package cj.web.sc.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.sc.domain.SCAddress;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCAddressDAO{
	
    @SQL("select * from SCAddress where id=:1")
    SCAddress queryById(String id);
    
    @SQL("INSERT INTO SCAddress (buyerId,receiverName,receiverPhone,province,city,area,address,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.buyerId,:t.receiverName,:t.receiverPhone,:t.province,:t.city,:t.area,:t.address,:t.deleteFlag,NOW(),:t.createUser,NOW(),:t.updateUser)")
    void create(@SQLParam("t") SCAddress sCAddress);
	
	@SQL("UPDATE SCAddress SET receiverName=:t.receiverName,receiverPhone=:t.receiverPhone,province=:t.province,city=:t.city,area=:t.area,address=:t.address,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") SCAddress sCAddress);
    
    @SQL("UPDATE SCAddress SET deleteFlag=0 WHERE id=:1")
    void deleteById(String id);

    @SQL("select * from SCAddress where deleteFlag=1 and buyerId=:t.buyerId order by isDefault desc,updateAt desc")
	List<SCAddress> queryByBuyerId(@SQLParam("t")SCAddress address);

    @SQL("select count(0) from SCAddress where deleteFlag=1 and buyerId=:t.buyerId")
	int sizeByBuyerId(@SQLParam("t")SCAddress address);
    
}